home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2000 September / maximum-cd-2000-09.iso / Vampire the Masquerade / vampire_demo.exe / Codex.nob / ClassWander.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-22  |  2.3 KB  |  66 lines

  1. public class ClassWander extends Codex {
  2.    private static final int TIMER_ID_WANDER = 0;
  3.    private static final int THINK_TIME = 2;
  4.    private static final int RESTART_BUFFER = 10;
  5.    private CodexActor _wanderThing = new CodexActor(((Codex)this).GetClassThing());
  6.    private float _minSearch;
  7.    private float _maxSearch;
  8.    private float _minDelay;
  9.    private float _maxDelay;
  10.    private float _speed;
  11.    private float _stepHeight;
  12.    private float[] pos = new float[3];
  13.    public static String[] _params = new String[]{"Min search radius;64", "Max search radius;320", "Min delay;2", "Max delay; 10", "Speed;210", "Step height to try; 16"};
  14.  
  15.    public void beginscene(int clientGuid, int captureID) {
  16.       this.SendThing();
  17.    }
  18.  
  19.    public void arrived(int thingGuid, int frameNum, int captureID) {
  20.       ((Codex)this).SetTimer((float)((double)this._minDelay + Math.random() * (double)(this._maxDelay - this._minDelay)), 0);
  21.    }
  22.  
  23.    public void SendThing() {
  24.       boolean bSuccess = false;
  25.       this.pos = this._wanderThing.GetPosition();
  26.       this.pos[0] += (float)(((double)this._minSearch + Math.random() * (double)(this._maxSearch - this._minSearch)) * (double)(Math.random() < (double)0.5F ? -1 : 1));
  27.       this.pos[1] += (float)(((double)this._minSearch + Math.random() * (double)(this._maxSearch - this._minSearch)) * (double)(Math.random() < (double)0.5F ? -1 : 1));
  28.  
  29.       while(!bSuccess) {
  30.          if (this._wanderThing.SendActorToPos(this.pos, this._speed)) {
  31.             bSuccess = true;
  32.             ((Codex)this).SetTimer(this._maxDelay + 10.0F, 0);
  33.          } else {
  34.             this.pos[2] += this._stepHeight;
  35.             if (!this._wanderThing.SendActorToPos(this.pos, this._speed)) {
  36.                ((Codex)this).SetTimer(2.0F, 0);
  37.                break;
  38.             }
  39.  
  40.             bSuccess = true;
  41.             ((Codex)this).SetTimer(this._maxDelay + 10.0F, 0);
  42.          }
  43.       }
  44.  
  45.    }
  46.  
  47.    public ClassWander(float minSearch, float maxSearch, float minDelay, float maxDelay, float speed, float stepHeight) {
  48.       this._minSearch = minSearch;
  49.       this._maxSearch = maxSearch;
  50.       this._minDelay = minDelay;
  51.       this._maxDelay = maxDelay;
  52.       this._speed = speed;
  53.       this._stepHeight = stepHeight;
  54.    }
  55.  
  56.    public void timer(int timerID, float arg0, float arg1, float arg2, float arg3) {
  57.       switch (timerID) {
  58.          case 0:
  59.             ((Codex)this).KillAllTimers();
  60.             this._wanderThing.Stop();
  61.             this.SendThing();
  62.          default:
  63.       }
  64.    }
  65. }
  66.